package jdbc2;
import org.apache.commons.dbutils.QueryRunner;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * Created by kevin on 2020/3/29.
 */
public class AccountDao {
    public void update(String name,double money){
        try {
            QueryRunner queryRunner = new TxQueryRunner();
            String sql = "update account set balance = balance+? where name = ?";
            Object [] params = {money,name};
            //需要保证多次调用的是同一个连接
//            Connection connection = JdbcUtils.getConnection();
            queryRunner.update(sql,params);
//            JdbcUtils.releaseConnection(connection);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
